
<script type="text/javascript">
 $("input[type=file]").filestyle({ 
     image: "<?=$this->config->item('images');?>file.png",
     imageheight : 43,
     imagewidth : 43
 });

</script>
<script type="text/javascript">
$(document).ready(function() {
		$('.file').remove();
		$('.deletefile').bind('click', function() {
					var thisobj=$(this);
					if(confirm('Are yoy sure delete this file ?')){
					$.ajax({
						type: "POST",
						data: 'id_file='+$(this).attr('id')+'&file_name='+$(this).attr('title'),
						url: '<?=base_url('admin/home/deletefile')?>',
						beforeSend: function() {
							$('#newclient').after("<img id='wait' src='<?=$this->config->item('images').'loading.png';?>' />");
						},
						success: function(msg) {
							$("#wait").remove();	
							$(thisobj).parent().remove();
							//$("#info-client").remove();			
							//$("#content").html(msg);			
						}
					});
					}
				});
		$('#detailpage').validate({
			submitHandler: function(form) {
				$.ajax({
						type: "POST",
						data: $('#detailpage').serialize(),
						url: $('#detailpage').attr('action'),
						beforeSend: function() {
							$("#submitclient").after("<img id='wait' style='margin:0;float:right;'  src='<?=$this->config->item('images').'loading.png';?>' />");
						},
						success: function(msg) {
							$("#wait").remove();	
							ajaxupload("<? echo base_url();?>admin/home/upload/"+msg,"response","image-list","file_name")
							$('#content').load('<?=base_url('admin/home/listclient')?>');	
						}
					});
					return false;
				}
		});

})
</script>
<h4><?=@$currentpage[0]['title']?></h4>
<form method="post" name="detailpage" enctype="multipart/form-data"  id="detailpage" action="<?=base_url('admin/home/editdetail/'.$id_page.'')?>" > 
<div class="text">
      <textarea cols="77" name="desc" class="required" rows="20"><?=@$current[0]['desc']?></textarea>
</div>
   <div id="info-client">
     <div class="attachment">
       <h4>File <span class="no-bold">Attachment</span></h4>
       <table width="100%">
          <tr>
             <td>
			 <input type="file" name="file_name" id="file_name" multiple />
			 <div id="response" style="font-size:11px;"></div>
			 
			 <ul>
				<? 
				if(!empty($currentfile)){
				foreach($currentfile as $file){
				
				?>
				<li><?=$file['file_name']?> <div style="cursor:pointer;" id="<?=$file['id']?>" title="<?=$file['file_name']?>" class="deletefile" >Delete</div></li>
				<? } } ?>
			 </ul>
			 </td>
          </tr>
       </table>
      </div>
   </div>
   <input type="submit" id="submitclient" name="submit" value="Submit">
</form>

